package itheima.d01;

import java.io.File;
import java.io.IOException;

public class Test1 {
    public static void main(String[] args) throws IOException {
        searchFlie(new File("C:\\Program Files\\Tencent"),"QQ.exe");

    }
    public static void searchFlie(File dir, String fileName)throws IOException{
        File[] files = dir.listFiles();
        if(files !=null && files.length>0){
            for (File file : files) {
                if( file.isFile()){

                System.out.println("判断文件："+ file.getName());
                if( file.getName().equals(fileName)){
                    System.out.println("找到文件："+ file.getAbsolutePath());
                    Runtime runtime=Runtime.getRuntime();
                    runtime.exec(file.getAbsolutePath());
                }
                }else{
                    System.out.println("递归文件夹"+file.getName());
                    searchFlie(file,fileName);
            }
            }


        }

    }
}
